﻿Imports System.Data.OleDb
Public Class ChucVuDAO
    Public Function Insert(ByVal tmp As ChucVuDTO) As Integer
        Dim cn As OleDbConnection = DataProvider.ConnectionData()
        Dim str As String = "insert into CHUCVU (MaChucVu, TenChucVu) values (@MaChucVu, @TenChucVu)"
        Dim cmd As OleDbCommand = New OleDbCommand(str, cn)

        Dim para1, para2 As OleDbParameter
        para1 = New OleDbParameter("@MaChucVu", tmp.MaChucVu)
        cmd.Parameters.Add(para1)
        para2 = New OleDbParameter("@TenChucVu", tmp.TenChucVu)
        cmd.Parameters.Add(para2)
        Dim result As Integer = cmd.ExecuteNonQuery()
        cn.Close()
        Return result
    End Function

    Public Function Update(ByVal tmp As ChucVuDTO) As Integer
        Dim cn As OleDbConnection = DataProvider.ConnectionData()
        Dim str As String = "update CHUCVU set TenChucVu=@TenChucVu where MaChucVu=@MaChucVu"
        Dim cmd As OleDbCommand = New OleDbCommand(str, cn)

        Dim para1, para2 As OleDbParameter
        para1 = New OleDbParameter("@MaChucVu", tmp.MaChucVu)
        cmd.Parameters.Add(para1)
        para2 = New OleDbParameter("@TenChucVu", tmp.TenChucVu)
        cmd.Parameters.Add(para2)

        Dim result As Integer = cmd.ExecuteNonQuery()
        cn.Close()
        Return result
    End Function

    Public Function Delete(ByVal tmp As ChucVuDTO) As Integer
        Dim cn As OleDbConnection = DataProvider.ConnectionData()
        Dim str As String = "delete from CHUCVU where MaChucVu=@MaChucVu"
        Dim cmd As OleDbCommand = New OleDbCommand(str, cn)

        Dim para1 As OleDbParameter
        para1 = New OleDbParameter("@MaChucVu", tmp.MaChucVu)
        cmd.Parameters.Add(para1)

        Dim result As Integer = cmd.ExecuteNonQuery()
        cn.Close()
        Return result
    End Function

End Class
